
export type FlowData = {
    // 基础信息
    modelInfo: ModelInfo
    // 表单相关
    formProperties: FormProperties
    formComponentList: DesignFormComponent[]
    // flowDesign相关
    zoomConfig: number
    nextNodeId: number
    flowNodeList: DesignFlowNode[],
    // 设计器模式 0：设计，1：查看设计(不能保存发布)，2：流程初始提交，3：运行时处理（审批，转交等），4：用户查看流程情况 ，5：运行时处理（用户重新提交任务）
    mode: string
    // 当前步骤
    currentStep: string,
    instanceInfo?: InstanceInfo
    taskList: Task[]
    triggerList: Trigger[]
}

export type Trigger = {
    springBeanName: string
    desc: string
    label: string
}

export type ModelInfo = {
    modelId: string
    modelVersion: number
    modelName: string
    modelGroup?: string
    modelStatus?: string
    sort?: number
}

export type FormComponent = {
    componentCode: string
    componentName: string
    componentType: string
    componentRequired: string
    componentSpan: number
    componentPlaceholder?: string
    componentOptions?: string[]
    componentTitlePlacement?: "center" | "left" | "right"
    componentLineDashed?: string
    componentValue?: any
}

export type ViewComponent = {
    componentId: string
    isDragging: boolean
    isSelected: boolean
}

export type DesignFormComponent = FormComponent & ViewComponent

export type FormProperties = {
    xGap: number
    labelPlacement: string
    labelWidth: number
    requireMarkPlacement: "right" | "left"
}

export type UserInfo = {
    userId: string
    userName: string
    orgCode: string
    orgName: string
    birthday: string
    sex: string
    nationality: string
    telephone: string
    email: string
    address: string
    userAvatar: string
    remark: string
}

export type RoleInfo = {
    roleCode: string
    roleName: string
}

export type OrgInfo = {
    orgCode: string
    orgName: string
}

export type FlowNodeConfig = {
    // 审批人类型
    approvalType?: string
    // 审批人ID列表
    approvalList?: string[]
    // 审批人列表
    approvalUserList?: UserInfo[]
    // 审批角色列表
    approvalRoleList?: RoleInfo[]
    // 审批部门列表
    approvalOrgList?: OrgInfo[]
    // 审批人类型为：多级领导时，审批领导层级
    approvalEnd?: number
    // 多人审批通过方式
    multiApprovalType?: string
    // 审批不通过类型
    approvalRefusedType?: string
    // 审批不通过时，指定跳转审批节点Id
    approvalRefusedToNodeId?: number
    // 条件表达式
    conditionExpression?: string
    // 触发对象（spring-bean-name）
    triggerTarget?: string
}

export type FlowNode = {
    nodeId: number
    nodeName: string
    nodeType: string  // 0：开始、1：审批、2：条件、3：条件分支、4：并行、5：并行分支、6：触发、9：结束
    parentNodeId: number
    children?: DesignFlowNode[]
    branchNodeList?: DesignFlowNode[]
    config: FlowNodeConfig
    taskStatus?: string
}

export type DesignFlowNode = FlowNode & { isEdit: boolean, isNameEdit: boolean }

export const approvalTypeList = [
    { label: "指定人员", value: "0" },
    { label: "指定角色", value: "1" },
    { label: "指定部门", value: "2" },
    // { label: "多级领导", value: "3" }
]

export type InstanceInfo = {
    userId: string
    instanceId: string
    modelId: string
    modelVersion: number
    instanceName: string
    instanceStatus: string
    formData: string
    createTime: string
    endTime: string
    userInfo: UserInfo
}

export type Task = {
    instanceId: string
    taskId: string
    taskName: string
    taskType: string
    parentTaskId: string
    branchTaskId: string
    nodeId: number
    taskStatus: string
    isDeleted: string
    createTime: string
    endTime: string
    taskProperties: Map<String, String>
    userTaskList: UserTask[]
    taskCommentList: TaskComment[]
}

export type UserTask = {
    userTaskId: string
    instanceId: string
    taskId: string
    userId: string
    userTaskStatus: string
    createTime: string
    endTime: string
    userInfo: UserInfo
}

export type TaskComment = {
    commentId: string
    instanceId: string
    taskId: string
    userId: string
    message: string
    createTime: string
    userInfo: UserInfo
}

export type ApprovalData = {
    message: string
}